<template>
	<view class="content">
		<view class="dizhi">
			<view class="dizhi1" v-for="(item, id) in list" :key="id">
				<view class="dizhi12">
					
				<view class="dizhi1-left">
					<view class="dizhi-left-name" @click="dataClick(item)">
						<span class="span1">{{item.name}}</span>
						<span class="span2">{{item.phone}}</span>
						</view>
				</view>
				<view class="dizhi1-right">
					<view class="dizhi1-right-shan" @click="ajp">
						<uni-icons type="trash" size="14"></uni-icons>
					</view>
					<view class="dizhi1-right-xin">
						<uni-icons type="compose" size="14"></uni-icons>
					</view>
				</view>
				</view>
				<view class="dizhi13">
					{{item.dizhi}}
				</view>
			</view>
		<!-- 	<view class="dizhi1">
				<view class="dizhi12">
				<view class="dizhi1-left">
					<view class="dizhi-left-name">
						<span class="span1">王大锤</span>
						<span class="span2">188 6886 6622</span>
						</view>
				</view>
				<view class="dizhi1-right">
					<view class="dizhi1-right-shan">
						<uni-icons type="trash" size="14"></uni-icons>
					</view>
					<view class="dizhi1-right-xin">
						<uni-icons type="compose" size="14"></uni-icons>
					</view>
				</view>
				</view>
				<view class="dizhi13">
					山东省济南市历下区解放东路街道华新路6号楼911
				</view>
			</view> -->
		</view>
	<!-- 	<view @click="goNewaddress2">
					
						新增地址
					
				</view> -->
		<view class="di-btn" @click="goNewaddress">
			<view class="di-btn2">
				新增地址
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		props:{
			tabBars:Array,
			tabIndex: [],
			name:'',//接收携带的name
		},
		data() {
			return {
				name:'',
				list: [
					{
						'id': '0',
						'name': '王大锤',
						'phone': '188 6886 6622',
						'dizhi': '山东省济南市先行区王大佬庄183号无名氏街道蛋蛋花园一号楼12单元1128',
					},
					{
						'id': '1',
						'name': '李四',
						'phone': '188 6886 6622',
						'dizhi': '北京市东城区和平里东街中关村雍和航星科技制造园区37号楼213',
					}
				],
				addresslist: '',// 收货地址列表
				addressId:'',//收货地址ID
			};
		},
		onLoad(parameter) {
			console.log(parameter,8)
			this.name = parameter.name
			console.log(this.name, '拿到的name值')
			this.addressList()
		},
		methods: {
			
			ajp(){
				
				uni.showModal({
				    title: '确认删除',
				    content: '确定是否删除地址',
				    success: (res) => {  
						if (res.confirm) {
						    console.log('用户点击确定');
							this.deleteAddress()
						} else if (res.cancel) {
						    console.log('用户点击取消');
						}
					}
				        
				});
			},
			// 用户删除收货地址
			deleteAddress () {
			var that = this
			that.$http.req.ajax({
			     path: ':8069/web/mall/addressDelete',
				 header: {
				       'token': uni.getStorageSync('token')
				      },
			     data: {
			     addressId: '99',// 收货地址ID
			     },
			     afterAjax: (res) => {
					 		console.log(res,'用户删除收货地址接口')
					 		if (res.code !== 200) {
					 			uni.showToast({
					 				// title: res.msg,
									title: '用户删除收货地址论错误，稍后重试',
					 				icon: 'none'
					 			})
					 			console.log(res.msg,'用户删除收货地址拿到')
					 		}
					 		if (res.code == 200) {
					 			console.log('用户删除收货地址通了')
								uni.showToast({
									title: '地址已删除',
									icon: 'none'
								})
					 		}
							 
			     }
			    })
				},
				
			
			// 查询用户收货地址列表
			addressList () {
				var that = this
				that.$http.req.ajax({
				     path: ':8069/web/mall/addressList',
					 header: {
					       'token': uni.getStorageSync('token')
					      },
				  //    data: {
				  //    commodityId: that.commodityId,// 商品ID
					 // evaluateInfo: that.evaluateInfo,// 评论信息
					 // evaluateType: that.evaluateType // 新增商品评论
				  //    },
				     afterAjax: (res) => {
						 		console.log(res,'查询用户收货地址列表接口')
						 		if (res.code !== 200) {
						 			uni.showToast({
						 				// title: res.msg,
										title: '查询用户收货地址列表论错误，稍后重试',
						 				icon: 'none'
						 			})
						 			console.log(res.msg,'查询用户收货地址列表拿到')
						 		}
						 		if (res.code == 200) {
						 			console.log('查询用户收货地址列表通了')
									// uni.showToast({
									// 	title: '已点赞',
									// 	icon: 'none'
									// })
						 		}
								 
				     }
				    })
			},
			      dataClick(i){
					  console.log(i, '地址详情点击')
			                let that = this;
							console.log(that.name)
			                var navData = JSON.stringify(i); // 这里转换成 字符串
							if (that.name == '0') {
									console.log('0000')
								uni.navigateTo({
									// url: '../mall/cart/cart?index='+navData
									url: './indet?index='+navData
								})
							} 
							if (that.name == '1') {
								console.log('1111')
								uni.navigateTo({
									// url: '../mall/cart/cart?index='+navData
									url: './indet2?index='+navData
								})
							} 
			            },
			// tabtap(index) {
			// 	this.$emit('tabtap',index);
			// 	console.log(index,'888')
			// },
			goNewaddress() {
				uni.navigateTo({
					url: 'new-address'
				})
			},
			goNewaddress2() {
				uni.navigateTo({
					url: 'address2/address2'
				})
			}
		}
	}
</script>

<style lang="scss">
.content {
	background-color: #f5f5f5;
	height: 1097rpx;
	.dizhi {
		margin: 21rpx;
		.dizhi1 {
			margin-bottom: 21rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			background-color: #FFFFFF;
			.dizhi12 {
				
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				.dizhi1-left {
					margin: 25rpx 21rpx 36rpx 30rpx;
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					.span1 {
						font-size: 27rpx;
						font-weight: 600;
					}
					.span2 {
						margin-left: 36rpx;
						font-size: 23rpx;
						color: #a6a6a6;
					}
				}
				.dizhi1-right {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					margin: 36rpx 21rpx 0 0;
					.dizhi1-right-shan {
						margin-right: 61rpx;
					}
				}
			}
			.dizhi13 {
				font-size: 21rpx;
				color: #959595;
				margin: 0 32rpx 30rpx 32rpx;
			}
		}
	}
	.di-btn {
		position: fixed;
		bottom: 0;
		width: 750rpx;
		height: 105rpx;
		.di-btn2 {
			margin: 21rpx 12rpx;
			width: 706rpx;
			height: 79rpx;
			border-radius: 39rpx;
			line-height: 79rpx;
			text-align: content;
			font-size: 25rpx;
			font-weight: 600;
			background-color: #fcda22;
			display: flex;
			flex-direction: row;
			justify-content: center;
		}
	}
}
</style>
